﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Gargoyle.ZZT
{
    public delegate void CheatDelegate(Game g, byte modifier);

	/// <summary>
	/// Contains Cheat code.
	/// </summary>
    static class Cheats
    {
		/// <summary>
		/// Cheat code for AMMO.
		/// </summary>
        public static void Ammo(Game g, byte modifier)
        {
            g.Info.Ammo += (Int16)g.Parameters.AmmoPerPickup;
        }

		/// <summary>
		/// Cheat code for DARK.
		/// </summary>
		public static void Dark(Game g, byte modifier)
        {
            if (g.Parameters.TorchesEnabled)
            {
                g.CurrentBoard.Dark = modifier;
                g.RedrawBoard();
            }
        }

		/// <summary>
		/// Cheat code for GEMS.
		/// </summary>
		public static void Gems(Game g, byte modifier)
        {
            g.Info.Gems += 5;
        }

		/// <summary>
		/// Cheat code for HEALTH.
		/// </summary>
		public static void Health(Game g, byte modifier)
        {
            g.Info.Health += 50;
        }

		/// <summary>
		/// Cheat code for KEYS.
		/// </summary>
		public static void Keys(Game g, byte modifier)
        {
            for (int i = 0; i < g.Info.Keys.Length; i++)
                g.Info.Keys[i] = 1;
        }

		/// <summary>
		/// Cheat code for NOZ.
		/// </summary>
		public static void NoStones(Game g, byte modifier)
        {
            if (g.Parameters.StonesEnabled)
                g.Info.Stones = -1;
        }

		/// <summary>
		/// Cheat code for Z.
		/// </summary>
		public static void Stones(Game g, byte modifier)
        {
            if (g.Parameters.StonesEnabled)
                g.Info.Stones++;
        }

		/// <summary>
		/// Cheat code for TIME.
		/// </summary>
		public static void Time(Game g, byte modifier)
        {
            g.Info.TimePassed -= 30;
        }

		/// <summary>
		/// Cheat code for TORCHES.
		/// </summary>
		public static void Torches(Game g, byte modifier)
        {
            if (g.Parameters.TorchesEnabled)
                g.Info.Torches += 3;
        }

		/// <summary>
		/// Cheat code for ZAP.
		/// </summary>
		public static void Zap(Game g, byte modifier)
        {
            Thing player = g.Things[0];

            for (int i = 0; i < 4; i++)
            {
                Location target = player.Location.Add(g.Parameters.CardinalVectors[i]);
                g.DestroyAt(target);
                g.SetElementAt(target, g.Elements[ElementID.Empty]);
                g.UpdateAt(target);
            }
        }
    }
}